/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package de.saar.penguin.give2.server.alert;

import de.saar.penguin.give2.server.BigBrother;
import de.saar.penguin.give2.server.DescribedObject;
import de.saar.penguin.give2.server.Instruction;
import de.saar.penguin.give2.server.RoomDescription;
import de.saar.penguin.give2.server.RoomDescriptionType;
import de.saar.penguin.give2.server.SaarNlgSystem;

/**
 *
 * @author koller
 */
public class RememberRoomAlert extends Alert {
    private final RoomDescription description;
    private final String targetRoom;

    public RememberRoomAlert(SaarNlgSystem nlg, RoomDescription description) {
        super(nlg);
        this.description = description;
        this.targetRoom = description.getRoom().getId();
        this.diesInCreateInstruction = false;
        this.highLevel = true;
    }

    @Override
    public boolean isActivated(BigBrother bb) {
        if (getCurrentRoom().equals(targetRoom)) {
            if (description.getType() == RoomDescriptionType.WALLPAPERS) {
                finished = true;
                return true;
            } else {
                for (DescribedObject object : description.getTargets()) {
                    if (nlg.visible.contains(object.getId())) {
                        finished = true;
                        return true;
                    }
                }
            }
        }
        finished = false;
        return false;
    }

    @Override
    public Instruction getInstruction() {
        Instruction instr = nlg.instructionGenerator.createInstruction(nlg.visible);
        instr.customInstructionPhrase = "This is " + description.getDescription() + ", remember that!";
        return instr;
    }

    public RoomDescription getDescription() {
        return description;
    }

    

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final RememberRoomAlert other = (RememberRoomAlert) obj;
        if (this.description != other.description && (this.description == null || !this.description.equals(other.description))) {
            return false;
        }
        if ((this.targetRoom == null) ? (other.targetRoom != null) : !this.targetRoom.equals(other.targetRoom)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 67 * hash + (this.description != null ? this.description.hashCode() : 0);
        hash = 67 * hash + (this.targetRoom != null ? this.targetRoom.hashCode() : 0);
        return hash;
    }


}
